package com.ruoyi.paiban.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.paiban.mapper.PaibanbiaoMapper;
import com.ruoyi.paiban.domain.Paibanbiao;
import com.ruoyi.paiban.service.IPaibanbiaoService;

/**
 * 排班Service业务层处理
 *
 * @author ruoyi
 * @date 2023-05-26
 */
@Service
public class PaibanbiaoServiceImpl implements IPaibanbiaoService
{
    @Autowired
    private PaibanbiaoMapper paibanbiaoMapper;

    /**
     * 查询排班
     *
     * @param id 排班主键
     * @return 排班
     */
    @Override
    public Paibanbiao selectPaibanbiaoById(Long id)
    {
        return paibanbiaoMapper.selectPaibanbiaoById(id);
    }

    /**
     * 查询排班列表
     *
     * @param paibanbiao 排班
     * @return 排班
     */
    @Override
    public List<Paibanbiao> selectPaibanbiaoList(Paibanbiao paibanbiao)
    {
        return paibanbiaoMapper.selectPaibanbiaoList(paibanbiao);
    }

    /**
     * 新增排班
     *
     * @param paibanbiao 排班
     * @return 结果
     */
    @Override
    public int insertPaibanbiao(Paibanbiao paibanbiao)
    {
        return paibanbiaoMapper.insertPaibanbiao(paibanbiao);
    }

    /**
     * 修改排班
     *
     * @param paibanbiao 排班
     * @return 结果
     */
    @Override
    public int updatePaibanbiao(Paibanbiao paibanbiao)
    {
        return paibanbiaoMapper.updatePaibanbiao(paibanbiao);
    }

    /**
     * 批量删除排班
     *
     * @param ids 需要删除的排班主键
     * @return 结果
     */
    @Override
    public int deletePaibanbiaoByIds(Long[] ids)
    {
        return paibanbiaoMapper.deletePaibanbiaoByIds(ids);
    }

    /**
     * 删除排班信息
     *
     * @param id 排班主键
     * @return 结果
     */
    @Override
    public int deletePaibanbiaoById(Long id)
    {
        return paibanbiaoMapper.deletePaibanbiaoById(id);
    }

    /**
     * 删除排班信息
     *
     * @param paibanbiao 排班主键
     * @return 结果
     */
    @Override
    public int deletePaibanbiaoByDay(Paibanbiao paibanbiao)
    {
        return paibanbiaoMapper.deletePaibanbiaoByDay(paibanbiao);
    }

    /**
     * 查询该天排班列表
     *
     * @param paibanbiao 排班
     * @return 排班
     */
    @Override
    public List<Paibanbiao> selectPaibanbiaoListByDay(Paibanbiao paibanbiao)
    {
        return paibanbiaoMapper.selectPaibanbiaoListByDay(paibanbiao);
    }

    @Override
    public void qiandao() {
        //获取当前登录用户id
        Long id = SecurityUtils.getUserId();
        //获取当前登录用户
        String username = SecurityUtils.getUsername();

        Paibanbiao paibanbiao =  new Paibanbiao();
        paibanbiao.setDate(new Date());
        paibanbiao.setYuangongName(username);
        paibanbiao.setQiandaoStatus("1");
        paibanbiao.setId(id);
        paibanbiaoMapper.updatePaibanbiao(paibanbiao);
    }
}
